﻿<MEditor @ref="@_editor" @bind-Value="_editorContent" Placeholder="请输入内容" ContentStyle="height:100px">
</MEditor>
<MRow Align="@AlignTypes.Center"
      Justify="@JustifyTypes.SpaceAround" Class="mt-10">
      <MButton Depressed Color="primary" @onclick="GetTextAsync">
        获取文本
    </MButton>
    <MButton Depressed Color="primary" @onclick="GetContentAsync">
        获取内容
    </MButton>
    <MButton Depressed Color="primary" @onclick="GetHtmlAsync">
        获取html
    </MButton>
    <MButton Depressed Color="primary" @onclick="SetHtmlAsync">
        设置html
    </MButton>
    <MButton Depressed Color="primary" @onclick="DisableAsync">
        禁用
    </MButton>
    <MButton Depressed Color="primary" @onclick="EnableAsync">
        启用
    </MButton>
</MRow>
<MAlert Border="Borders.Top"
            ColoredBorder
            Type="AlertTypes.Info"
            Elevation="2" 
            Class="overflow-auto mt-10">
        @_viewContent
</MAlert>

@code {
    private MEditor _editor;
    private string _editorContent = @"Hello MEditor";
    private string _viewContent;

    public async Task GetTextAsync()
    {
        _viewContent = await this._editor.GetTextAsync();
    }
    public async Task GetContentAsync()
    {
        _viewContent = await this._editor.GetContentAsync();
    }
    public async Task GetHtmlAsync()
    {
        _viewContent = await this._editor.GetHtmlAsync();
    }

    public async Task SetHtmlAsync()
    {
        string html =
            @"<a href='https://www.baidu.com/'>" +
            "<img src='https://www.baidu.com/img/flexible/logo/pc/result.png' /></a>";

        await this._editor.SetHtmlAsync(html);
    }
    public async Task DisableAsync()
    {
        await this._editor.DisableAsync();
    }
    public async Task EnableAsync()
    {
        await this._editor.EnableAsync();
    }
}